home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* */
- /* ------------ Bit-Bucket Software <no-Inc> */
- /* \ 10001101 / Writers and Distributors of */
- /* \ 011110 / No-Cost<no-tm> Software. */
- /* \ 1011 / */
- /* ------ KopyRong (K) 1987. ALL RIGHTS REVERSED. */
- /* */
- /* */
- /* This module was written by Vince Perriello */
- /* */
- /* */
- /* BinkleyTerm Nodelist processing module */
- /* */
- /* */
- /* This software package is being distributed WITH FULL SOURCE CODE */
- /* with the following conditions: 1) If anything awful happens */
- /* because you use it (or don't use it), you accept full */
- /* responsibility; 2) you don't start making tons of voice calls to */
- /* the authors to complain or make suggestions about enhancements, */
- /* useful or otherwise; 3) you do not reuse this code in commercial */
- /* products without specific permission to do so from the authors; */
- /* 4) If you find any problems you send fixes to the authors for */
- /* inclusion in updates; 5) You find some way to express your */
- /* appreciation for this method of distribution, either by writing */
- /* code or application notes, or just sending along a "Thank You" */
- /* message. */
- /* */
- /* There is copyrighted code in this product. We either wrote it */
- /* ourselves or got permission to use it. Please don't force us to */
- /* pay a lawyer -- have some respect for our motives and don't abuse */
- /* this "license". */
- /* */
- /* */
- /*--------------------------------------------------------------------------*/
-
- #include <sys\types.h>
- #include <sys\stat.h>
- #include <stdio.h>
- #include <fcntl.h>
- #include <signal.h>
- #include <ctype.h>
- #include <conio.h>
- #include "com.h"
- #include "xfer.h"
- #include "keybd.h"
-
- extern struct pointers ctl; /* where all the strings is */
- int autobaud = 0; /* Use highest baud rate when calling out */
- struct _node nodedes; /* desc. of node */
- static struct _ndi *node_index = NULL; /* pointer to node array */
- static int idx_size = 0; /* number of entries in it */
-
- /*---------------------------------------------------------------------------*/
- /* NODEPROC */
- /* Find nodelist entry and set baud to nodelist baud for dialing out */
- /*---------------------------------------------------------------------------*/
-
- nodeproc(nodeaddr)
- char *nodeaddr;
- {
- int opusnet,opusnode; /* net and node */
- char *c,*skip_blanks();
-
- c = skip_blanks(nodeaddr); /* get rid of the blanks */
- if (sscanf(c,"%d/%d",&opusnet,&opusnode) != 2)
- {
- status_line("!Can't convert Net/Node address");
- return(0);
- }
- if (!nodefind(opusnet,opusnode)) /* if we can't find the node */
- return(0); /* go away now */
- status_line ("*Processing node %d/%d -- %s",opusnet,opusnode,nodedes.name);
- if (!CARRIER) /* if no carrier yet, */
- {
- if (autobaud)
- set_baud (ctl.max_baud, 1); /* Set to our highest baud rate */
- else
- set_baud(nodedes.rate,1); /* set baud to nodelist baud */
- }
- return(1); /* return success to caller */
- }
-
- /*---------------------------------------------------------------------------*/
- /* NODEFIND */
- /* Find nodelist entry for use by other routines (password, nodeproc) */
- /* If found, result will be in "nodedes". */
- /*---------------------------------------------------------------------------*/
-
- nodefind(opusnet,opusnode)
- int opusnet,opusnode; /* net and node */
- {
- register struct _ndi *nodeidx; /* index file */
- int foundnet = 0; /* 'found the net' flag */
- int found = 0; /* 'found the node' flag */
- long nodeoff = 0L; /* offset into nodelist.sys */
- char temp[80]; /* where we build filenames */
- int i;
- FILE *stream;
- struct stat f;
-
- if (node_index == NULL)
- {
- temp[0] = '\0'; /* "null-terminated string" */
- strcpy(temp,ctl.net_info); /* take nodelist path */
- strcat(temp,"NODELIST.IDX"); /* add in the file name */
- if ((stream = fopen(temp,"rb")) == NULL)/* OK, let's open the file */
- {
- status_line("!Unable to open Nodelist.Idx file");
- return(0); /* no file, no work to do */
- }
- fstat (fileno(stream),&f); /* get file statistics */
- i = f.st_size; /* size of index file, */
- idx_size = i / sizeof(struct _ndi); /* number of index entries */
- node_index = (struct _ndi *)malloc(i);
- if (node_index == NULL)
- {
- status_line("!Unable to allocate memory for Nodelist Index");
- fclose(stream);
- return(0);
- }
- if (fread(node_index,i,1,stream) != 1)
- {
- status_line("!Failed to read nodelist index into memory");
- return(0);
- }
- fclose(stream);
- }
- nodeidx = node_index;
- for (i = 1; i <= idx_size; i++)
- {
- if (nodeidx->net == opusnet) /* if a match on net, */
- {
- foundnet = 1; /* say we found the net */
- if (((opusnode == 0) && (nodeidx->node <= 0))
- || (nodeidx->node == opusnode)) /* see if we found the node */
- {
- found = 1; /* say we found it */
- break; /* get out */
- }
- }
- else
- if (foundnet) /* already past the net? */
- break; /* Yes, we failed... */
- nodeoff += sizeof(nodedes); /* keep track of .SYS offset */
- ++nodeidx; /* bump to next index pointer*/
- }
-
- if (!found)
- {
- status_line("!Couldn't find Net/Node: %d/%d",opusnet,opusnode);
- return(0);
- }
-
- strcpy(temp,ctl.net_info); /* take nodelist path */
- strcat(temp,"NODELIST.SYS"); /* add in the file name */
- if ((stream = fopen(temp,"rb")) == NULL) /* OK, let's open the file */
- {
- status_line("!Unable to open Nodelist.Sys file");
- return(0);
- }
-
- if (fseek(stream,nodeoff,SEEK_SET)) /* try to point at record */
- {
- status_line("!Unable to position to node record in Nodelist.Sys");
- fclose(stream);
- return(0);
- }
-
- if (!fread(&nodedes,sizeof(nodedes),1,stream))
- {
- status_line("!Not able to read node record from Nodelist.Sys");
- fclose(stream);
- return(0);
- }
- fclose(stream);
-
- return(1);
- }
-